package com.easyJava.bean;

import com.easyJava.utils.PropertiesUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * 这是一个常量类
 */
public class Constants {


    //XML的信息
    public static final String PATH_MAPPER_XML;

    //Query的信息
    public static final String query_string_suffix;
    public static final String query_date_start;
    public static final String query_date_end;



    //Mapper的信息
    public static final String MAPPER_NAME;
    public static final String PACKAGE_MAPPER;
    public static final String PATH_MAPPER;



    // Enums的包和路径
    public static final String PATH_ENUMS;
    public static final String PACKAGE_ENUMS;

    // Query的包和路径
    public static final String PACKAGE_QUERY;
    public static final String PATH_QUERY;
    public static final String IS_QUERY;
    public static final String QUERY_NAME;


    public static final String PACKAGE= "package ";

    // 工具类的名字
    public static final String DATETIMEPATTERNENUM = "DateTimePatternEnum";
    public static final String DATEUTILS = "DateUtil";
    public static final String BASEMAPPER = "BaseMapper";
    public static final String SIMPLEPAGE = "BaseMapper";

    private static final Logger logger = LoggerFactory.getLogger(Constants.class);


    // Util的包和路径
    public static final String PATH_UTIL;
    public static final String PACKAGE_UTIL;


    public static final String BEAN_NAME = "bean";

    public static final String OVERRIDE = "@Override";
    public static final String STRING_TYPE = "String";
    public static final String PUBLIC = "public";

    // 这是要去忽视Json的字段
    public static final String ignore_bean_toJson_field;
    public static final String ignore_bean_toJson_expression;
    public static final String ignore_bean_toJson_class;

    // 日期格式化
    public static final String bean_date_format_expression;
    public static final String bean_date_format_class;
    // 日期解析
    public static final String bean_date_unformat_expression;
    public static final String bean_date_unformat_class;

    /**
     * private 字段
     */
    public static final String PRIVATE = "private";


    public static final String AUTHOR_NAME ;
    private static final Logger log = LoggerFactory.getLogger(Constants.class);

    /**
     *  是否忽略表
     */
    public static Boolean IS_IGNORE_TABLE ;

    /**
     * bean后缀
     */
    public static String SUFFIX_BEAN;


    public static String  PATH_JAVA = "java";
    public static String PATH_RESOURCES = "resources";


    /**
     * 项目路径
     */
    public static String PATH_BASE;

    /**
     * po路径
     */
    public static String PATH_PO;

    /**
     * po包名
     */
    public static String PACKAGE_BASE;

    /**
     * po包名
     */
    public static String PACKAGE_PO;


    static {

        //Query的信息
        query_string_suffix = PropertiesUtils.getProperties("query.string.suffix");
        query_date_start = PropertiesUtils.getProperties("query.date.start");
        query_date_end = PropertiesUtils.getProperties("query.date.end");

        IS_IGNORE_TABLE = Boolean.valueOf( PropertiesUtils.getProperties("IS.IGNORE.TABLE"));
        SUFFIX_BEAN = PropertiesUtils.getProperties("suffix.bean.param");

        //项目路径
        PATH_BASE = PropertiesUtils.getProperties("path.base");
        PACKAGE_BASE = PropertiesUtils.getProperties("path.base") + "/" + PATH_JAVA + "/"+ PropertiesUtils.getProperties("package.name");
        PACKAGE_BASE= PACKAGE_BASE.replaceAll("\\.","/");
        PATH_PO = PACKAGE_BASE + "/" + PropertiesUtils.getProperties("package.po");
        PATH_PO = PATH_PO.replaceAll("\\.","/");
        PACKAGE_PO = PropertiesUtils.getProperties("package.name") + "." + PropertiesUtils.getProperties("package.po");

        //Utils的路径与包
        PATH_UTIL = PACKAGE_BASE + "/" + PropertiesUtils.getProperties("package.util").replaceAll("\\.","/");
        PACKAGE_UTIL = PropertiesUtils.getProperties("package.name") + "." + PropertiesUtils.getProperties("package.util");
        //Enums的包和路径
        PATH_ENUMS = PACKAGE_BASE + "/" + PropertiesUtils.getProperties("package.entity.enums").replaceAll("\\.","/");
        PACKAGE_ENUMS = PropertiesUtils.getProperties("package.name") + "." + PropertiesUtils.getProperties("package.entity.enums");
        //Query的包和路径
        PATH_QUERY = PACKAGE_BASE + "/" + PropertiesUtils.getProperties("package.query").replaceAll("\\.","/");
        PACKAGE_QUERY = PropertiesUtils.getProperties("package.name") + "." + PropertiesUtils.getProperties("package.query");
        IS_QUERY = PropertiesUtils.getProperties("is.query");
        QUERY_NAME = PropertiesUtils.getProperties("query.name");
        //Mapper的名字，包，路径
        MAPPER_NAME = PropertiesUtils.getProperties("mapper.name");
        PACKAGE_MAPPER = PropertiesUtils.getProperties("package.name") + "." + PropertiesUtils.getProperties("package.mapper");
        PATH_MAPPER = PACKAGE_BASE + "/" + PropertiesUtils.getProperties("package.mapper").replaceAll("\\.","/");
        //XML的路径
        PATH_MAPPER_XML = PropertiesUtils.getProperties("path.base") + "/" + PATH_RESOURCES +"/"+  PropertiesUtils.getProperties("package.mapper").replaceAll("\\.","/");



        //作者
        AUTHOR_NAME = PropertiesUtils.getProperties("author.name");


        ignore_bean_toJson_field = PropertiesUtils.getProperties("ignore.bean.toJson.field");
        ignore_bean_toJson_expression = PropertiesUtils.getProperties("ignore.bean.toJson.expression");
        ignore_bean_toJson_class = PropertiesUtils.getProperties("ignore.bean.toJson.class");

        bean_date_format_expression = PropertiesUtils.getProperties("bean.date.format.expression");
        bean_date_format_class = PropertiesUtils.getProperties("bean.date.format.class");

        bean_date_unformat_expression = PropertiesUtils.getProperties("bean.date.unformat.expression");
        bean_date_unformat_class = PropertiesUtils.getProperties("bean.date.unformat.class");
    }

    public final static String[] SQL_DATE_TIME_TYPES = new String[]{"datetime","timestamp"};

    public final static  String[] SQL_DATE_TYPES = new String[]{"date"};

    public final static String[] SQL_DECIMAL_TYPES=new String[]{"decimal","double","float"};

    public final static String[] SQL_STRING_TYPES = new String[]{"char","varchar","text","longtext","mediumtext"};

    public final static String[] SQL_INT_TYPES = new String[]{"int","tinyint"};

    public final static String[] SQL_LONG_TYPES = new String[]{"bigint"};

    public static void main(String[] args) {
        System.out.println(PACKAGE_PO);
        System.out.println(PATH_PO);
        System.out.println(PATH_UTIL);
        System.out.println(PACKAGE_UTIL);
        System.out.println(PATH_ENUMS);
        System.out.println(PACKAGE_ENUMS);
        System.out.println(PACKAGE_QUERY);
        System.out.println(PATH_QUERY);
        System.out.println(PATH_MAPPER_XML);
    }
}
